﻿
using UnityEngine;

namespace Gameplay
{
    public class AudioManager:MonoBehaviour
    {
        private static AudioManager _instance;
        public static AudioManager Instance => _instance;

        private AudioSource _audioSource;
        private void Awake()
        {
            if (_instance == null) 
            {
                _instance = this;
            }
            if(!gameObject.TryGetComponent<AudioSource>(out _audioSource)) 
            {
                _audioSource =gameObject.AddComponent<AudioSource>();
            }
        }
        public void PlaySound(AudioClip audioClip) 
        {
            _audioSource.clip = audioClip;
            _audioSource.PlayOneShot(audioClip);
        }

    }
}
